package com.wry.cloud.controller;

import com.wry.cloud.entity.Payment;
import com.wry.cloud.service.PaymentService;
import com.wry.cloud.utils.ApiResult;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <h1> 支付业务控制器集群cp1 </h1>
 *
 * @author <a href="mailto::15671496069@163.com">WeiRuYuan</a>
 * @since 2022/9/4
 */
@RestController
@RequestMapping("payment")
public class PaymentController {

    @Resource
    private PaymentService paymentService;

    @Value("${server.port}")
    private String serverPort;

    @PostMapping
    public ApiResult<Object> insert(@RequestBody Payment payment){
        paymentService.insert(payment);
        return new ApiResult<>(200,"插入成功，集群端口："+serverPort);
    }

    @GetMapping("{id}")
    public ApiResult<Payment> getPaymentById(@PathVariable Long id){
       return new ApiResult<>(200,"订单流水号，集群端口："+serverPort,paymentService.getPaymentById(id));
    }
}
